package com.foreknow.dao;

import com.foreknow.entity.User;
import org.apache.commons.dbutils.ResultSetHandler;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

public interface BaseDao<T> {
    /**
     * 删除
     * @param sql
     * @param params
     * @return
     * @throws SQLException
     */
     public  int delete(String sql,Object...params) throws SQLException;

    /**
     * 删除 参数不一样
     * @param sql
     * @return
     * @throws SQLException
     */
    public  int delete(String sql) throws SQLException;

    /**
     * 添加
     * @param sql
     * @param params
     * @return
     * @throws SQLException
     */
    public  int insert (String sql ,Object...params) throws SQLException;

    /**
     * 根据条件查询
     * @param sql
     * @return
     * @throws SQLException
     */
    public List<T> queryByCondition(String sql) throws  SQLException;

    /**
     * 条件查询
     * @param sql
     * @param params
     * @return
     * @throws SQLException
     */
    public List<User> queryByCondition(String sql, Object...params) throws  SQLException;

    /**
     * 查询一个对象
     * @param sql
     * @param params
     * @return
     * @throws SQLException
     */
    public  T queryOne(String sql, Object...params) throws  SQLException;

    /**
     * 修改
     * @param sql
     * @param params
     * @return
     * @throws SQLException
     */
    public  int update(String sql, Object...params) throws  SQLException;

    /**
     * 修改 参数不一样
     * @param sql
     * @param params
     * @return
     * @throws SQLException
     */
    public  int update(String sql, Object params) throws  SQLException;

    /**
     *
     * @return
     */
    public ResultSetHandler <T> getResultSetHandler();

}
